<%@page import="com.solution.common.config.PublicConfig"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %> 
<c:set var="rootPath" value="<%=PublicConfig.ROOT_PATH%>" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="overflow: hidden;">
  <head>
  	<base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>景旭分销 </title>
    <!-- 网站图标@xu_cc -->
    <link rel="icon" href="${pageContext.request.contextPath}/statics/images/jx.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/statics/images/jx.ico" type="image/x-icon" />
    <link rel="bookmark" href="${pageContext.request.contextPath}/statics/images/jx.ico" type="image/x-icon" />

    <!-- Bootstrap -->
    <link href="<%=basePath%>/statics/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="<%=basePath%>/statics/css/font-awesome.min.css" rel="stylesheet"> 
    <!-- bootstrap3-dialog -->
	<link href="<%=basePath%>/statics/plugins/bootstrap3-dialog/css/bootstrap-dialog.min.css" rel="stylesheet"> 
	<!-- Custom Theme Style -->
    <link href="<%=basePath%>/statics/css/custom.css?v=20180116" rel="stylesheet"> 
  </head>
  <body class="nav-md" style="background:#f7f7f7">
	
	<c:set var="mainPage" value=""></c:set>
	<jsp:include page="./browser_check.jsp" />
    <div class="container body">
      <div class="main_container" style="height:900px;overflow-y:auto;">
        <div class="col-md-3 left_col" style="overflow-y:auto;height:100%;overflow-x:hidden">
          <div class="left_col scroll-view" >
            <div class="navbar nav_title" style="border: 0;">
              <a href="javascript: window.location.reload();" class="site_title"><i class="fa fa-truck"></i> <span>景旭分销管理后台</span></a>
            </div>
            <div class="clearfix"></div>
            <br />
            <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
              <div class="menu_section"> 
               <ul class="nav side-menu">
                <c:if test="${userMenuList != null}">
					<c:forEach items="${userMenuList}" var="menu" varStatus="status">
						<h3 id="MenuFrame_${status.index}" xIndex="${status.index}">
							<c:if test="${menu.childList == null}">
								<li><a href="${rootPath}${subMenu.url}" target="iframepage"><i class="fa fa-home"></i> ${menu.resourceName} 
								<span class="fa fa-chevron-right"></span></a> </li>
							</c:if>
						</h3>
						<c:if test="${menu.childList != null}">
						  <li><a><s></s><i class="${menu.iconClass }"></i>${menu.resourceName} &nbsp;
						  		<span class="fa fa-chevron-down"></span>
						  		<c:if test="${menu.resourceIntro eq 'parent_will_audit_badge' && pendingApprovalCount ne null && pendingApprovalCount ne 0 }">
						  			<c:if test="${isSalesman eq 0 }">
										<span style="background-color: #d15b47!important;font-size:14px;" class="badge pendingApproval">${pendingApprovalCount }</span>
						  			</c:if>
								</c:if>
						  	  </a>
							   <ul class="nav child_menu">
									<c:if test="${menu.childList != null}">
										<c:forEach items="${menu.childList}" var="subMenu">
											<c:if test="${empty mainPage }">
												<c:set var="mainPage" value="${rootPath}${subMenu.url}"></c:set>
											</c:if>
											<li>
												<a href="${rootPath}${subMenu.url}" target="iframepage">
													${subMenu.resourceName} &nbsp;
													<c:if test="${subMenu.resourceIntro eq 'will_audit_badge' && pendingApprovalCount ne null && pendingApprovalCount ne 0}">
														<c:if test="${isSalesman eq 0 }">
															<span style="background-color: #d15b47!important;font-size:14px;" class="badge pendingApproval">${pendingApprovalCount }</span>
														</c:if>
													</c:if>
												</a>
											</li> 
										</c:forEach>
									</c:if>
							   </ul>
						   </li>
						</c:if>
					</c:forEach>
				 </c:if>
               </ul>
              </div>
            </div>
          </div>
        </div>

        <!-- top navigation -->
        <div class="top_nav">
          <div class="nav_menu">
            <nav>
              <div class="nav toggle">
                <a id="menu_toggle"><i class="fa fa-bars"></i></a>
              </div>
			  <div class="nav nav-brand">
				 <a  onclick="javascript: window.location.reload();" ><i class="fa fa-home"> 主页</i></a> 
			  </div>
              <ul class="nav navbar-nav navbar-right">
                <li class="">
                  <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                   <c:if test="${path !=null && path !=''}">
                      <img src="<%=PublicConfig.IMG_ROOT_URL%>${path }" alt="" />
                   </c:if>
                     <c:if test="${path ==null || path ==''}">
                      <img src="${rootPath}/statics/images/img.jpg" alt="" />
                   </c:if>
                   ${currUserName}
                    <span class=" fa fa-angle-down"></span>
                  </a>
                  <ul class="dropdown-menu dropdown-usermenu pull-right"> 
                    <li>
                      <a href="javascript:modifyPassword()" id="modifyPassword" ><i class="fa fa-lock pull-right"></i> 密码设置</a>
                    </li> 
                    <li><a href="javascript:void(0);" id="back_logout"><i class="fa fa-sign-out pull-right"></i> 安全退出</a></li>
                  </ul>
                </li> 
	          
	          	<!-- 非业务员可以看到待办事项 begin -->
	          	<input type="hidden" id="isSalesman" value="${isSalesman}" />
	          	<c:if test="${isSalesman eq 0 }">
	          		<shiro:hasPermission name="verifyOrderPage">
	                <li class="dropdown">
						<a id="to_check" href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
							<i class="fa fa-credit-card"></i>  
							<span>待核销</span>
							<span class="badge badge-danger">${TO_CHECK }</span>
						</a>
					</li>
	          		</shiro:hasPermission>
	          		<shiro:hasPermission name="sendOrderPage">
					<li class="dropdown">
						<a id="to_send"  href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
							<i class="fa fa-send-o"></i> 
							<span>待发货</span>
							<span class="badge badge-purple">${TO_SEND }</span>
						</a>
					</li>
	          		</shiro:hasPermission>
	          		<shiro:hasPermission name="approveOrderPage">
					<li class="dropdown">
						<a id="to_approve"  href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
							<i class="fa fa-file-text-o"></i> 
							<span>待审核</span>
							<span class="badge badge-primary">${TO_APPROVE }</span>
						</a>
					</li>
	          		</shiro:hasPermission>
	          		<shiro:hasPermission name="companyPage">
					<li class="dropdown">
						<a id="to_approve_customer"  href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
							<i class="fa fa-user-o"></i> 
							<span>待审核客户</span>
							<span class="badge badge-warning">${TO_APPROVE_CUSTOMER }</span>
						</a>
					</li>
	          		</shiro:hasPermission>
	          	</c:if>
	          	<!-- 非业务员可以看到待办事项 end -->
			</ul>
              
            </nav>
          </div>
        </div>
        <div class="right_col"> 
          <div class="row"> 
           <iframe src="${mainPage}" id="iframepage"  name="iframepage" scrolling="yes"  width="100%" height="100%"  onload="changeFrameHeight()" frameborder="0"></iframe>
          </div>
        </div>
        <!-- /footer content -->
      </div>
    </div>
    <!-- jQuery -->
    <script src="${rootPath}/statics/js/jquery.1.11.3.min.js"></script>
    <!-- Bootstrap -->
    <script src="${rootPath}/statics/js/bootstrap.min.js"></script>    
    <!-- bootstrap3-dialog  -->
	<script src="${rootPath}/statics/plugins/bootstrap3-dialog/js/bootstrap-dialog.min.js"></script>   
    <!-- layer -->
	<script type="text/javascript" src="<%=basePath%>/statics/plugins/layer/layer.js"></script>
    <!-- Custom Theme Scripts -->
    <script src="${rootPath}/statics/js/custom.js"></script>
	<script>
		var rootPath = '<%=basePath %>'; //相对
	
		function changeFrameHeight(){
			var ifm= document.getElementById("iframepage"); 
			ifm.height = document.documentElement.clientHeight-100;
		}
		window.onresize = function(){  
			 changeFrameHeight();  
		} 
		
		<%-- function home(href){
			if(href==1){
				$("#iframepage").attr("src", "<%=basePath%>/home/toAdminHomePage");
			}else if(href==2){
				$("#iframepage").attr("src", "<%=basePath%>/home/toSalesmanHomePage");
			}else if(href==3){
				$("#iframepage").attr("src", "<%=basePath%>/home/toDealerHomePage");
			}
		} --%>
		$(function() {
			
			// 返回首页面
			$("#back_logout").click(function(){
				window.location.href = "${pageContext.request.contextPath}/logout";
			});
			
			// 待审核客户
			$("#to_approve_customer").click(function(){
				var url = rootPath+"/registerMgmt/toListCustomerPage";
				resetMenu(url);
				$("#iframepage").attr("src", url);
			});
			
			// 待审核订单
			$("#to_approve").click(function(){
				var url = rootPath+"/order/toListToApproveOrderPage?orderStatus=02";
				resetMenu(url);
				$("#iframepage").attr("src",rootPath+"/order/toListToApproveOrderPage?orderStatus=02");
			});
			
			// 待发货
			$("#to_send").click(function(){
				var url = rootPath+"/order/toListToSendOrderPage?orderStatus=04";
				resetMenu(url);
				$("#iframepage").attr("src",rootPath+"/order/toListToSendOrderPage?orderStatus=04");
			});
			
			// 待核销
			$("#to_check").click(function(){
				var url = rootPath+"/order/toListVerifyOrderPage?orderStatus=08";
				resetMenu(url);
				$("#iframepage").attr("src",rootPath+"/order/toListVerifyOrderPage?orderStatus=08");
			});
			
			//定时刷新待办信息
			if ($("#isSalesman").val() == "0") { 
				var timer = setInterval(refreshAlertBadge, 50000000); 
			}
		});
		
		//刷新右上角待审核等数字提示和左侧菜单待审核客户数
		function refreshAlertBadge(){
			$('.pendingApproval').hide();
			$.ajax({
				type: 'POST',
				url: rootPath + "/indexController/getTodoList",
				async: true,
				dataType: 'json',
				success: function(json) {
					if(json.resultCode == '1') {
						// 待审核客户
						if ($("#to_approve_customer .badge").length > 0) {
							//眉头
							$("#to_approve_customer .badge").html(json.TO_APPROVE_CUSTOMER); 
							//左侧菜单
							if (json.TO_APPROVE_CUSTOMER != '0') {
								$('.pendingApproval').html(json.TO_APPROVE_CUSTOMER).show();
							}
						}
						// 待审核订单
						if ($("#to_approve .badge").length > 0) {
							$("#to_approve .badge").html(json.TO_APPROVE); 
						}
						// 待发货
						if ($("#to_send .badge").length > 0) {
							$("#to_send .badge").html(json.TO_SEND);
						}
						// 待核销
						if ($("#to_check .badge").length > 0) {
							$("#to_check .badge").html(json.TO_CHECK);
						}
					} 
				}
			});
			
		}
		
		//重定位当前选中菜单
		function resetMenu(url) {  
			$('#sidebar-menu').find(".active").toggleClass();
			$('#sidebar-menu').find("a").each(function(){ 
				var menu_url = $(this).attr('href'); 
				if(url && $(this).attr('target') == 'iframepage' && url.replace(/\//g, '').indexOf(menu_url.replace(/\//g, '')) > -1) { 
					$('#sidebar-menu').find('li ul').slideUp();
					$(this).parent().addClass('active');
					$($(this).parent().parent()).slideDown();
				}
			})
		}
		
		//修改密码
		function modifyPassword(){
			sys.showRemote(rootPath + '/user/toModifyPwd', function(){
				var code =sys.dialog.getData("code"); 
				var message =sys.dialog.getData("message"); 
				if(code != 2){
					if(code == '1'){
					    sys.showSuccess(message,function(){
					    	// window.location.href="${pageContext.request.contextPath}";
					    	//退出重新登录
					    	window.location.href = rootPath + "/logout";
					    });
					}else{
						sys.showErr(message);
					}
				}
			}, {title: '修改密码', width: 600, height: 600});
		}
	</script>
  </body>
</html>
